# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making BK-ITSM 蓝鲸流程服务 available.

Copyright (C) 2021 THL A29 Limited, a Tencent company.  All rights reserved.

BK-ITSM 蓝鲸流程服务 is licensed under the MIT License.

License for BK-ITSM 蓝鲸流程服务:
--------------------------------------------------------------------
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

# Generated by Django 1.11.24 on 2020-04-03 17:39
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.manager
import jsonfield.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('creator', models.CharField(max_length=64, verbose_name='创建人')),
                ('create_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('update_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('updated_by', models.CharField(max_length=64, verbose_name='修改人')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否软删除')),
                ('signal', models.CharField(max_length=128, verbose_name='触发事件信号')),
                ('sender', models.CharField(help_text='一般为触发该信号的元素id', max_length=64, verbose_name='触发对象')),
                ('schema_id', models.IntegerField(verbose_name='事件关联的配置信息')),
                (
                    'source_type',
                    models.CharField(
                        default='', help_text='记录响应事件的来源类型, 由用户自定义，方便使用方后期管理', max_length=64, verbose_name='响应事件来源类型'
                    ),
                ),
                ('source_id', models.IntegerField(blank=True, null=True, verbose_name='对应的来源PK值')),
                ('context', jsonfield.fields.JSONField(default={}, verbose_name='触发事件的上下文参数')),
                ('inputs', jsonfield.fields.JSONField(default={}, help_text='输入参数引用的参数变量', verbose_name='用户的输入参数')),
                (
                    'status',
                    models.CharField(
                        choices=[('CREATED', '新建'), ('RUNNING', '执行中'), ('SUCCEED', '成功'), ('FAILED', '失败')],
                        default='CREATED',
                        max_length=64,
                        verbose_name='响应事件状态',
                    ),
                ),
                ('end_time', models.DateTimeField(null=True, verbose_name='任务结束事件')),
                ('operator', models.CharField(default='SYS', max_length=64, verbose_name='执行人')),
                ('ex_data', jsonfield.fields.JSONField(default={}, help_text='状态为失败的时候记录的错误日志', verbose_name='执行错误信息')),
            ],
            options={'verbose_name': '响应动作参数配置表', 'verbose_name_plural': '响应动作参数配置表', 'ordering': ('-id',),},
            managers=[('_objects', django.db.models.manager.Manager()),],
        ),
        migrations.CreateModel(
            name='ActionSchema',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('creator', models.CharField(max_length=64, verbose_name='创建人')),
                ('create_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('update_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('updated_by', models.CharField(max_length=64, verbose_name='修改人')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否软删除')),
                ('name', models.CharField(max_length=255, verbose_name='动作模版的名称')),
                ('display_name', models.CharField(max_length=255, null=True, verbose_name='动作显示名称')),
                ('component_type', models.CharField(max_length=255, verbose_name='组件类型')),
                (
                    'operate_type',
                    models.CharField(
                        choices=[('MANUAL', '手动执行'), ('BACKEND', '后台执行')],
                        default='BACKEND',
                        max_length=64,
                        verbose_name='操作方式',
                    ),
                ),
                ('can_repeat', models.BooleanField(default=False, verbose_name='是否可以重复执行')),
                ('params', jsonfield.fields.JSONField(default={}, help_text='当前响应事件配置的参数模版', verbose_name='配置参数')),
                ('inputs', jsonfield.fields.JSONField(default={}, help_text='输入参数引用的参数变量', verbose_name='输入参数')),
            ],
            options={'verbose_name': '响应动作参数配置表', 'verbose_name_plural': '响应动作参数配置表', 'ordering': ('-id',),},
            managers=[('_objects', django.db.models.manager.Manager()),],
        ),
        migrations.CreateModel(
            name='Trigger',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('creator', models.CharField(max_length=64, verbose_name='创建人')),
                ('create_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('update_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('updated_by', models.CharField(max_length=64, verbose_name='修改人')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否软删除')),
                ('name', models.CharField(max_length=64, verbose_name='名称')),
                ('signal', models.CharField(max_length=128, verbose_name='触发事件信号')),
                ('sender', models.CharField(help_text='一般为触发该信号的实际对象模型id', max_length=64, verbose_name='触发对象')),
                ('inputs', jsonfield.fields.JSONField(default=[], help_text='输入参数引用的参数变量', verbose_name='输入参数')),
                (
                    'source_type',
                    models.CharField(
                        choices=[('basic', '公共'), ('workflow', '流程'), ('ticket', '流程版本'), ('task', '任务')],
                        help_text='触发规则的配置来源',
                        max_length=64,
                        verbose_name='来源类型',
                    ),
                ),
                ('source_id', models.IntegerField(blank=True, null=True, verbose_name='对应的来源PK值')),
                ('is_draft', models.BooleanField(default=True, verbose_name='是否为草稿')),
                ('is_enabled', models.BooleanField(default=False, verbose_name='是否可启用')),
                (
                    'icon',
                    models.CharField(
                        choices=[('message', '消息'), ('status', '修改状态'), ('user', '修改处理人'), ('API', 'API接口')],
                        default='',
                        max_length=64,
                        verbose_name='对应的icon',
                    ),
                ),
            ],
            options={'verbose_name': '触发器', 'verbose_name_plural': '触发器',},
            managers=[('_objects', django.db.models.manager.Manager()),],
        ),
        migrations.CreateModel(
            name='TriggerRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('creator', models.CharField(max_length=64, verbose_name='创建人')),
                ('create_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('update_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('updated_by', models.CharField(max_length=64, verbose_name='修改人')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='是否软删除')),
                ('condition', jsonfield.fields.JSONCharField(default={}, max_length=255, verbose_name='触发条件')),
                (
                    'action_schemas',
                    jsonfield.fields.JSONCharField(
                        default=[], help_text='关联事件的配置ID列表,关联actionSchema', max_length=255, verbose_name='响应事件列表'
                    ),
                ),
                ('rule_id', models.IntegerField(null=True, verbose_name='对应的触发器id')),
            ],
            options={'verbose_name': '触发器条件与动作配置', 'verbose_name_plural': '触发器',},
            managers=[('_objects', django.db.models.manager.Manager()),],
        ),
    ]
